import 'package:flutter/material.dart';
import 'package:bip39/bip39.dart' as bip39;
import 'package:itoken/Components/CRouter.dart';

class PHome extends StatelessWidget {
  _generateMnemonic() async {
    String randomMnemonic = bip39.generateMnemonic();
    print('助记词 ====> $randomMnemonic');
    CRouter.showMnemonic(mnemonic: randomMnemonic);
    // String seed = bip39.mnemonicToSeedHex(randomMnemonic);
    // KeyData master = ED25519_HD_KEY.getMasterKeyFromSeed(seed);
    // String privateKey = HEX.encode(master.key);
    // print('私钥 ====> $privateKey');
    // final private = EthPrivateKey.fromHex(privateKey);
    // final address = await private.extractAddress();
    // print('eth地址 ====> $address');
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Token"),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            RaisedButton(
              onPressed: _generateMnemonic,
              child: Text("生成助记词"),
            ),
            RaisedButton(
              onPressed: CRouter.importType,
              child: Text("钱包导入"),
            ),
          ],
        ),
      ),
    );
  }
}
